<script setup>
import {ref,onMounted} from 'vue'
import { useRoute } from 'vue-router'
import http from '/src/utils/http.js'

const route=useRoute();
let id = route.params.id;

const user=ref(null)

const getUser=async()=>{
    const response=await http.get('/user/getUserById',{
      params:{id:id}
    },)
    user.value=response.data
}

onMounted(()=>{
    console.log('请求用户数据id:'+id);
    getUser();
}
)
</script>

<template>
<div>
    <h1>个人中心</h1>
    <div v-if="user">
        <p>{{ user.name }}</p>
        <p>{{ user.gender }}</p>
        <p>{{ user.birthday }}</p>
        <p>{{ user.email }}</p>
    </div>
</div>
</template>